package com.ang.mybatisplus.multiDataSource.controller;

import com.ang.mybatisplus.multiDataSource.model.UserModel;
import com.ang.mybatisplus.multiDataSource.service.IUserMasterService;
import com.ang.mybatisplus.multiDataSource.service.IUserSlaveService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

@RestController
public class TestController {
    @Autowired
    IUserMasterService userMasterService;

    @Autowired
    IUserSlaveService userSlaveService;

    @RequestMapping("/testMulti")
    public Object testMulti(){
        UserModel userModelMaster = userMasterService.getById(1);

        UserModel userModelSlave = userSlaveService.getById(1);

        Map<String,UserModel> map = new HashMap<>();
        map.put("master", userModelMaster);
        map.put("slave", userModelSlave);

        return map;
    }
}
